Skip to content

aspose-html-cloud/aspose-html-cloud-cpp

Repository files navigation

Aspose HTML Cloud SDK C++

AsposeHtml - the C++ library for the Aspose.HTML Cloud API Reference

  • API version: 4.0
  • Package version: 22.12.1

Installation

Get ready package or build from source.

Install from command line

PM> NuGet\Install-Package aspose.html.cloud.v143 -Version 22.12.1

Load from git

git clone https://github.com/aspose-html-cloud/aspose-html-cloud-cpp.git
cd aspose-html-cloud-cpp

Getting Started

To use Aspose HTML for Cloud SDK you need to register an account with Aspose Cloud and lookup/create App Key and SID at Cloud Dashboard. There is free quota available. For more details, see Aspose Cloud Pricing.

Possible conversions:

  • HTML -> PDF, XPS, DOCX, MD, MHTML, JPEG, BMP, PNG, TIFF, GIF
  • EPUB -> PDF, XPS, DOCX, JPEG, BMP, PNG, TIFF, GIF
  • MD -> PDF, XPS, DOCX, HTML, MHTML, JPEG, BMP, PNG, TIFF, GIF
  • MHTML -> PDF, XPS, DOCX, JPEG, BMP, PNG, TIFF, GIF
  • SVG -> PDF, XPS, JPEG, BMP, PNG, TIFF, GIF
  • JPEG, BMP, PNG, TIFF, GIF -> SVG

All URIs are relative to https://api.aspose.cloud/v4.0

ConversionApi

Method Description
сonvertLocalToLocal Convert a document from the local disk to the local disk.
сonvertLocalToStorage Convert a document from the local disk to the storage.
сonvertStorageToLocal Convert a document from the storage to the local disk.
сonvertStorageToStorage Convert a document from the storage to the storage.
сonvertUrlToLocal Convert the website to the local disk.
сonvertUrlToStorage Convert the website to the storage.

VectorizationApi

Method Description
vectorizeLocalToLocal Vectorize image to SVG format from the local disk to the local disk.
vectorizeLocalToStorage Vectorize image to SVG format from the local disk to the storage.
vectorizeStorageToLocal Vectorize image to SVG format from the storage to the local disk.
vectorizeStorageToStorage Vectorize image to SVG format from the storage to the storage.
#include <AsposeHtmlCloud.h>

using namespace com::aspose::api;


int main(int argc, char* argv[])
{
    // Get current directory
    std::string cur_dir(argv[0]);
    int pos = cur_dir.find_last_of("/\\");
    cur_dir = cur_dir.substr(0, pos + 1); // Include the last slash
    std::wstring w_cur_dir(cur_dir.begin(), cur_dir.end());

    // Get keys from aspose site.
    // There is free quota available. 
    // For more details, see https://purchase.aspose.cloud/pricing

    const utility::string_t clientId = _XPLATSTR("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
    const utility::string_t clientSecret = _XPLATSTR("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    const utility::string_t basePath = _XPLATSTR("https://api.aspose.cloud/v4.0");
    const utility::string_t authPath = _XPLATSTR("https://api.aspose.cloud/connect/token");

    // Create configuration for authorization
    std::shared_ptr<ApiConfiguration> apiConfig(new ApiConfiguration(clientId, clientSecret, basePath, authPath));

    // Create client from configuration
    std::shared_ptr<ApiClient> apiClient(new ApiClient(apiConfig));

    // Create ConversionApi
    std::shared_ptr<ConversionApi> api = std::make_shared<ConversionApi>(apiClient);
 
    // File name for conversion
    utility::string_t src = w_cur_dir + _XPLATSTR("test.html");
    utility::string_t dst = w_cur_dir + _XPLATSTR("result.jpeg");
    
    // Set options for conversion
    std::shared_ptr<ConversionOptions> opts = std::make_shared<ConversionOptions>();
    opts->setWidth(800)         // Size in pixels for images, for output formats PDF, XPS, DOCX - in inches.
        ->setHeight(600)        // Size in pixels for images, for output formats PDF, XPS, DOCX - in inches.
        ->setLeftMargin(10)     // Size in pixels for images, for output formats PDF, XPS, DOCX - in inches.
        ->setRightMargin(10)    // Size in pixels for images, for output formats PDF, XPS, DOCX - in inches.
        ->setTopMargin(10)      // Size in pixels for images, for output formats PDF, XPS, DOCX - in inches.
        ->setBottomMargin(10);  // Size in pixels for images, for output formats PDF, XPS, DOCX - in inches.
    
    //Conversion
    auto result = api->convertLocalToLocal(src, dst, opts);
    
    // Check the result file
    auto re = result->getFile();
    std::ifstream f(re.c_str());
    if(!f.good())
    {
        throw std::runtime_error("Conversion failed");
    }
}

ConversionOptions

Method Description Note
ConversionOptions* ConversionOptions::setWidth(double value) Width in inches for PDF, XPS, DOCX output formats. In pixels for images. Optional
ConversionOptions* ConversionOptions::setHeight(double value) Height in inches for PDF, XPS, DOCX output formats. In pixels for images. Optional
ConversionOptions* ConversionOptions::setLeftMargin(double value) Left margin in inches for PDF, XPS, DOCX output formats. In pixels for images. Optional
ConversionOptions* ConversionOptions::setRightMargin(double value) Right margin in inches for PDF, XPS, DOCX output formats. In pixels for images. Optional
ConversionOptions* ConversionOptions::setTopMargin(double value) Top margin in inches for PDF, XPS, DOCX output formats. In pixels for images. Optional
ConversionOptions* ConversionOptions::setBottomMargin(double value) Bottom margin in inches for PDF, XPS, DOCX output formats. In pixels for images. Optional
ConversionOptions* ConversionOptions::setJpegQuality(int value) Quality in percent (for PDF conversion only). Optional
ConversionOptions* ConversionOptions::setBackground(utility::string_t value) CSS background like '#FF0000'. For conversion from SVG only. Optional

Additional options for trace to the SVG format

Method Description Note
ConversionOptions* ConversionOptions::setErrorThreshold(double value) This parameter defines maximum deviation of points to fitted curve. By default it is 30. Optional
ConversionOptions* ConversionOptions::setMaxIteration(int value) This parameter defines number of iteration for least-squares approximation method. By default it is 30. Optional
ConversionOptions* ConversionOptions::setColorLimit(int value) The maximum number of colors used to quantize an image. Default value is 25. Optional
ConversionOptions* ConversionOptions::setLineWidth(double value) The value of this parameter is affected by the graphics scale. Default value is 1. Optional

Additional options for convert to the markdown format

Method Description Note
ConversionOptions* ConversionOptions::setUseGit(bool value) Use git flavor. True or False. Default false. Optional

Vectorization options for trace to the SVG format

Method Description Note
VectorizationOptions* VectorizationOptions::setErrorThreshold(double value) This parameter defines maximum deviation of points to fitted curve. By default it is 30. Optional
VectorizationOptions* VectorizationOptions::setMaxIteration(int value) This parameter defines number of iteration for least-squares approximation method. By default it is 30. Optional
VectorizationOptions* VectorizationOptions::setColorLimit(int value) The maximum number of colors used to quantize an image. Default value is 25. Optional
VectorizationOptions* VectorizationOptions::setLineWidth(double value) The value of this parameter is affected by the graphics scale. Default value is 1. Optional

Documentation for API Endpoints

All URIs are relative to https://api.aspose.cloud/v4.0

Examples

Requirements (for build from source)

oauth

Tests contain various examples of using the Aspose.HTML SDK.

All API in html format Documentation for Aspose.HTML Api SDK

About

C++ library for communicating with the Aspose.HTML Cloud API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •